package light.head.model.inv;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;

/**
 * 订单信息
 * @author yy
 *
 */
@Entity
@Table
public class InvOrderInfo implements Serializable{
	private static final long serialVersionUID = -2207031485849524793L;
	private Integer code;				// 流水号
	private Integer oc;					// 机构编号
	private Integer bc;					// 来往商编号
	private Byte type;					// 订单类型(1.销售订单 2.进货订单)
	private String dn;					// 单据编号
	private Integer cu;					// 创建人
	private Date ct;					// 创建时间
	private Boolean deleted = false;	// 是否删除
	
	private String cn;				// 创建人名称
	private String on;				// 机构名称
	private String bn;				// 来往商名称
	
	private List<InvOrderItem> itemList;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Integer getBc() {
		return bc;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Column
	public Byte getType() {
		return type;
	}
	@Column
	public String getDn() {
		return dn;
	}
	@Column(updatable = false, nullable = false)
	public Integer getCu() {
		return cu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	@Formula("(SELECT i.name FROM InvBusiness i WHERE i.code = bc)")
	public String getBn() {
		return bn;
	}
	@Transient
	public List<InvOrderItem> getItemList() {
		return itemList;
	}
	
	
	
	
	
	public void setItemList(List<InvOrderItem> itemList) {
		this.itemList = itemList;
	}
	public void setBn(String bn) {
		this.bn = bn;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	public void setOn(String on) {
		this.on = on;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setType(Byte type) {
		this.type = type;
	}
	public void setDn(String dn) {
		this.dn = dn;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setBc(Integer bc) {
		this.bc = bc;
	}
	
}	
